package com.yanqu.road.server.cmd.chefduel.process2;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.chefduel.ChefDuelProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.chefduel.CrossChefDuelMgr;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.C_CROSS_CHEF_DUEL2_PRE_JOIN_OTHER_TABLE, desc = "入座试吃（预判断,其他活动）")
public class CrossPreJoinOtherTableCmd extends CrossCommand {

    private int activityId;
    private long homeUserId;
    private long joinUserId;
    private int tableId;
    private int spoonId;
    //玩家自己范围内的活动
    private int trueActivityId;
    private int campId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ChefDuelProto.ChefDuel2PreJoinTableReqMsg reqMsg = ChefDuelProto.ChefDuel2PreJoinTableReqMsg.parseFrom(packet.getBytes());
        joinUserId = packet.getPlayerId();  //我的
        activityId = reqMsg.getActivityId();  //homeUserId
        homeUserId = reqMsg.getUserId();
        tableId = reqMsg.getTableId();
        spoonId = reqMsg.getSpoonId();
        if(reqMsg.hasOtherActivityId()){
            trueActivityId = reqMsg.getOtherActivityId(); //我的
        }
        campId = reqMsg.getCampId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossChefDuelMgr.preJoinOtherTable(activityId, serverId, joinUserId, homeUserId, tableId, spoonId, trueActivityId, campId);
    }

    @Override
    public void sendData() {
    }

}
